#ifndef _CCLI_CMD_H_
#define _CCLI_CMD_H_
#include "flag.h"
struct _ccli_cmd;
typedef struct _ccli_cmd CcliCmd;
//argv not contain cmd itself
typedef int CCLICmdHandler(int argc, char **argv);
struct _ccli_cmd{
    char *name;
    char *usage;
    char *shortName;
    char *longName;
    char *description;
    CcliCmd *subCmd;
    //bro cmd
    CcliCmd *nextCmd;
    //last subcmd for add
    CcliCmd *lastCmd;
    CCLICmdHandler *handler;
};

void CCLIUsage(CcliCmd *cmd);
void CCLIUsageExit(CcliCmd * cmd);
// CCLICmdInit: ./cmd subcmd. if arg not match subcmd'subcmd, then call handler
CcliCmd *CCLISubCmdInit(char *name, char *usage, CCLICmdHandler *handler);

// CCLICmdInit: the root cmd's name is "", it can't match any cmd name
CcliCmd *CCLIRootCmdInit(char *usage, CCLICmdHandler *handler);

// CCLICmdAddSubCmd: Add subcmd to cmd, add to cmd->subCmd->lastCmd->nextCmd
int CCLICmdAddSubCmd(CcliCmd *cmd, CcliCmd *subCmd);

// Exec: parse input argc and args
int CCLICmdExec(CcliCmd *cmd, int argc, char **argv);

#endif